<script type="text/javascript">
	function checkNothing(){
		if( (document.getElementById("referTo").value != "") &&
			(document.getElementById("priority").value != "" ) &&
			(document.getElementById("referNotes").value != "") ){
			document.forms[0].submit();	
		}else{
			alert("No field can be blank");
		}
	}
</script>

<div align=center style="display: inline-table; margin-right: 10px;">

<table class="fTable" align="center">
	<tr>
		<th colspan="4">Patient Referrals</th>
	</tr>
	<tr class="subHeader">
		<td>Send To</td>
		<td>Priority</td>
		<td>Notes</td>
		<td style="width: 60px;">Action</td>
	</tr>

	<%if(action.getPatientReferralsForOfficeVisit().size()==0){ %>
	<tr>
		<td colspan="4" style="text-align: center;">No Patient Referrals
		on record</td>
	</tr>
	<%} 
	
	else { 
		for(PatientReferralBean b : action.getPatientReferralsForOfficeVisit() ) { 
			PersonnelDAO personnelDAO = DAOFactory.getProductionInstance().getPersonnelDAO();
			PersonnelBean receiver = personnelDAO.getPersonnel(b.getReceiverID());

		%>
	<tr>
		<%if(b.getBeenRead()==0){ %>
		<td align=center><a
			href="./editPatientReferral.jsp?refID=<%= StringEscapeUtils.escapeHtml("" + (b.getId())) %>&ovID=<%= StringEscapeUtils.escapeHtml("" + (ovIDString)) %>"><%= StringEscapeUtils.escapeHtml("" + (receiver.getFullName())) %></a></td>
		<%} else{%>
		<td><%= StringEscapeUtils.escapeHtml(""+receiver.getFullName() )%></td>
		<%} %>
		<td><%= StringEscapeUtils.escapeHtml(""+b.getPriority() )%></td>
		<td><%= StringEscapeUtils.escapeHtml("" + (b.getReferralDetails())) %></td>
		<td><a
			href="javascript:removeID('removeReferID','<%= StringEscapeUtils.escapeHtml("" + ( b.getId() ) ) %>');">Cancel</a></td>
	</tr>
	<%		}
				}%>

	<tr>
		<th colspan="4" style="text-align: center;">New</th>
	</tr>
	<tr class="subHeader">
		<td>Send To</td>
		<td>Priority</td>
		<td>Notes</td>
		<td rowspan="2"><input type="button" id="addPatientReferral"
			onclick="checkNothing()" value="Add Referral"></td>
	</tr>
	<tr>
		<td align=center><input type="text" name="referTo" id="referTo"
			value="" maxlength=100></td>
		<td align=center><select name="priority" id="priority"
			style="font-size: 10px;">
			<option value="">-- Please Select a Priority --</option>
			<option value="1">1 - most urgent</option>
			<option value="2">2 - moderately urgent</option>
			<option value="3">3 - least urgent</option>
		</select></td>
		<td align=center><input type="text" name="referNotes"
			id="referNotes" value="" maxlength=500></td>
	</tr>
</table>
</div>